package io.renren.modules.job.task;

import io.renren.modules.noc.entity.NocBeerTicketMemberEntity;
import io.renren.modules.noc.service.NocBeerTicketMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

@Component("beerMemberTask")
public class BeerMemberTask implements ITask {

    @Autowired
    private NocBeerTicketMemberService nocBeerTicketMemberService;
    @Override
    public void run(String params) {
        List<NocBeerTicketMemberEntity> list = nocBeerTicketMemberService.getNocBeerTicketMemberEntity();
        for(NocBeerTicketMemberEntity nocBeerTicketMemberEntity:list){
            if((System.currentTimeMillis()-nocBeerTicketMemberEntity.getRefreshTime().getTime())>30000){
                nocBeerTicketMemberEntity.setErcode(nocBeerTicketMemberService.getNextErCodeBeer());
                nocBeerTicketMemberEntity.setRefreshTime(new Date());
                nocBeerTicketMemberService.updateById(nocBeerTicketMemberEntity);
            }
        }

    }
}
